#ifndef TCPSEVER_H
#define TCPSEVER_H

#include<stdlib.h>
#include<unistd.h>
#include<event.h>
#include<assert.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<arpa/inet.h>
#include<map>
#include<semaphore.h>
#include<iostream>
#include<vector>
#include"mpthread.h"
using namespace std;
extern sem_t semcount;
typedef class tcpsever
{
	public:
		tcpsever(char *ip,unsigned short port, int pth_num);
		~tcpsever(){}

		void run();
		 void create_socketpair();
		void create_pth();
	   void showcli_num(void *arg);

	private:	
		
		friend void listen_cb(int fd,short event,void *arg);
		friend void sock_0_cb(int fd,short event,void *arg);
		struct event_base* _base;//libevent
		int mpth_num;
		int _listen_fd;
		
		map<int,int> _pth_event_map;//对应线程监听量
	     vector<int>  _socketpair_base0;
		 vector<int>  _socketpair_base1;
}Tcpsever,*Ptcpsever;



#endif
